package github.kawaiior.yuanchuxiuzhen.common.entity.addon.model;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import github.kawaiior.yuanchuxiuzhen.common.entity.addon.WhitePondEntity;
import github.kawaiior.yuanchuxiuzhen.util.RenderUtil;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.util.math.MathHelper;

public class WhitePondEntityModel extends EntityModel<WhitePondEntity> {
    private final ModelRenderer Baize;
    
    private final ModelRenderer body;
    
    private final ModelRenderer tail;
    
    private final ModelRenderer Beard;
    
    private final ModelRenderer head;
    
    private final ModelRenderer horn;
    
    private final ModelRenderer bone;
    
    private final ModelRenderer horn2;
    
    private final ModelRenderer bone2;
    
    private final ModelRenderer Ears1;
    
    private final ModelRenderer Ears2;
    
    private final ModelRenderer rightleg;
    
    private final ModelRenderer leftleg;
    
    private final ModelRenderer leftarm;
    
    private final ModelRenderer rightarm;

    public WhitePondEntityModel(){
        this.textureWidth=64;
        this.textureHeight=64;
        this.Baize=new ModelRenderer(this);
        this.Baize.setRotationPoint(3.0F,24.0F,0.0F);
        RenderUtil.setRotationAngle(this.Baize,0.0F,-1.5708F,0.0F);
        this.body=new ModelRenderer(this);
        this.body.setRotationPoint(0.0F,0.0F,0.0F);
        this.Baize.addChild(this.body);
        addBox(this.body, 0, 0, -6.0F, -13.0F, 0.0F, 12, 5, 6, 0.0F, false);
        this.tail=new ModelRenderer(this);
        this.tail.setRotationPoint(6.9829F,-12.1294F,3.0F);
        RenderUtil.setRotationAngle(this.tail,0.0F,0.0F,0.2618F);
        this.body.addChild(this.tail);
        addBox(this.tail, 26, 19, -0.9829F, 0.1294F, -0.5F, 4, 1, 1, 0.0F, false);
        addBox(this.tail, 30, 11, 3.0171F, -0.3706F, -1.0F, 2, 2, 2, 0.0F, false);
        this.Beard=new ModelRenderer(this);
        this.Beard.setRotationPoint(-5.0F,-4.0F,0.0F);
        this.body.addChild(this.Beard);
        addBox(this.Beard, 18, 18, -3.0F, -7.0F, 1.0F, 2, 3, 4, 0.0F, false);
        addBox(this.Beard, 26, 15, -2.0F, -3.0F, 2.0F, 1, 1, 3, 0.0F, false);
        addBox(this.Beard, 22, 11, -3.0F, -4.0F, 2.0F, 1, 1, 3, 0.0F, false);
        addBox(this.Beard, 16, 11, -2.0F, -4.0F, 1.0F, 1, 1, 4, 0.0F, false);
        addBox(this.Beard, 10, 31, -2.0F, -7.0F, 5.0F, 1, 4, 1, 0.0F, false);
        addBox(this.Beard, 25, 15, -3.0F, -7.0F, 5.0F, 1, 2, 1, 0.0F, false);
        addBox(this.Beard, 0, 0, -4.0F, -7.0F, 2.0F, 1, 3, 2, 0.0F, false);
        addBox(this.Beard, 16, 11, -3.0F, -7.0F, 0.0F, 1, 2, 1, 0.0F, false);
        addBox(this.Beard, 6, 31, -2.0F, -7.0F, 0.0F, 1, 4, 1, 0.0F, false);
        addBox(this.Beard, 0, 31, -2.0F, -2.0F, 2.0F, 1, 1, 2, 0.0F, false);
        this.head=new ModelRenderer(this);
        this.head.setRotationPoint(-8.0F,-12.0F,0.0F);
        this.Baize.addChild(this.head);
        addBox(this.head, 0, 11, -2.0F, -4.0F, 0.0F, 5, 5, 6, 0.0F, false);
        this.horn=new ModelRenderer(this);
        this.horn.setRotationPoint(-1.0F,-4.0F,4.0F);
        RenderUtil.setRotationAngle(this.horn,-0.3491F,0.0F,0.3491F);
        this.head.addChild(this.horn);
        addBox(this.horn, 32, 0, 0.0F, -4.0F, 0.0F, 1, 4, 1, 0.0F, false);
        this.bone=new ModelRenderer(this);
        this.bone.setRotationPoint(0.5F,-1.0F,0.5F);
        RenderUtil.setRotationAngle(this.bone,-0.3491F,0.0F,0.6981F);
        this.horn.addChild(this.bone);
        addBox(this.bone, 32, 25, -0.5F, -2.0F, -0.5F, 1, 2, 1, 0.0F, false);
        this.horn2=new ModelRenderer(this);
        this.horn2.setRotationPoint(-1.0F,-4.0F,2.0F);
        RenderUtil.setRotationAngle(this.horn2,0.3491F,0.0F,0.3491F);
        this.head.addChild(this.horn2);
        addBox(this.horn2, 32, 32, 0.0F, -4.0F, -1.0F, 1, 4, 1, 0.0F, false);
        this.bone2=new ModelRenderer(this);
        this.bone2.setRotationPoint(0.5F,-1.0F,-0.5F);
        RenderUtil.setRotationAngle(this.bone2,0.3491F,0.0F,0.6981F);
        this.horn2.addChild(this.bone2);
        addBox(this.bone2, 31, 15, -0.5F, -2.0F, -0.5F, 1, 2, 1, 0.0F, false);
        this.Ears1=new ModelRenderer(this);
        this.Ears1.setRotationPoint(0.0F,-3.0F,0.0F);
        RenderUtil.setRotationAngle(this.Ears1,-0.3491F,0.0F,0.0F);
        this.head.addChild(this.Ears1);
        addBox(this.Ears1, 30, 21, -1.0F, 0.0F, -1.0F, 2, 3, 1, 0.0F, false);
        this.Ears2=new ModelRenderer(this);
        this.Ears2.setRotationPoint(0.0F,-3.0F,6.0F);
        RenderUtil.setRotationAngle(this.Ears2,0.3491F,0.0F,0.0F);
        this.head.addChild(this.Ears2);
        addBox(this.Ears2, 0, 11, -1.0F, 0.0F, 0.0F, 2, 3, 1, 0.0F, false);
        this.rightleg=new ModelRenderer(this);
        this.rightleg.setRotationPoint(2.0F,16.0F,4.0F);
        addBox(this.rightleg, 0, 37, -1.0F, 0.0F, -1.0F, 2, 8, 2, 0.0F, false);
        this.leftleg=new ModelRenderer(this);
        this.leftleg.setRotationPoint(-2.0F,16.0F,4.0F);
        addBox(this.leftleg, 8, 37, -1.0F, 0.0F, -1.0F, 2, 8, 2, 0.0F, false);
        this.leftarm=new ModelRenderer(this);
        this.leftarm.setRotationPoint(2.0F,16.0F,-5.0F);
        addBox(this.leftarm, 16, 25, -1.0F, 0.0F, -1.0F, 2, 8, 2, 0.0F, false);
        this.rightarm=new ModelRenderer(this);
        this.rightarm.setRotationPoint(-2.0F,16.0F,-5.0F);
        addBox(this.rightarm, 24, 25, -1.0F, 0.0F, -1.0F, 2, 8, 2, 0.0F, false);
        
        
    }

    private void addBox(ModelRenderer mb, int tx, int ty, float x, float y, float z, float width, float height, float depth, float delta, boolean mirrorIn){
        ModelRenderer mr = new ModelRenderer(this);
        mb.addChild(mr);
        mr.setTextureOffset(tx, ty).addBox(x,y,z,width,height,depth,delta,mirrorIn);
    }

    @Override
    public void setRotationAngles(WhitePondEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
        this.rightarm.rotateAngleX = MathHelper.cos(limbSwing * 1.0F) * 1.0F * limbSwingAmount;
        this.leftleg.rotateAngleX = MathHelper.cos(limbSwing * 1.0F) * 1.0F * limbSwingAmount;
        this.head.rotateAngleY = netHeadYaw / 57.295776F;
        this.head.rotateAngleX = headPitch / 57.295776F;
        this.rightleg.rotateAngleX = MathHelper.cos(limbSwing * 1.0F) * -1.0F * limbSwingAmount;
        this.leftarm.rotateAngleX = MathHelper.cos(limbSwing * 1.0F) * -1.0F * limbSwingAmount;
    }

    @Override
    public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {

        this.Baize.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.rightleg.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.leftleg.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.leftarm.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.rightarm.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        

    }
}